﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_ListAllAdmin : System.Web.UI.Page
{
    protected MODEL.Users user = new MODEL.Users();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["currentAdmin"] != null)
            {
                user = (MODEL.Users)Session["currentAdmin"];
                if (user.UserRoleId != 3)
                {
                    MessageBox.Show(this, "您没有权限");
                    MessageBox.script(this, "window.location='ListAllUsers.aspx';");
                }
            }
        }

    }

    #region 更新
    /// <summary>
    /// 更新
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ObdsAdmins_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
        if (Page.IsValid)
        {
            MODEL.Users updateUser = (MODEL.Users)e.InputParameters[0];
            updateUser.UId = Convert.ToInt32(((Label)gvUser.Rows[gvUser.EditIndex].FindControl("lbUId")).Text);
            
            BLL.Users blluser = new BLL.Users();
            MODEL.Users model= blluser.getModel(updateUser.UId);
            updateUser.QQ = model.QQ;
            updateUser.Question = model.Question;
            updateUser.Answer = model.Answer;
            updateUser.Email = model.Email;
            updateUser.Phone = model.Phone;

            updateUser.Pwd = ((TextBox)gvUser.Rows[gvUser.EditIndex].FindControl("txtPwd")).Text;
            updateUser.UserRoleId = Convert.ToInt32(((DropDownList)gvUser.Rows[gvUser.EditIndex].FindControl("ddlUserIdentity")).SelectedValue);
            updateUser.UserStateId = Convert.ToInt32(((DropDownList)gvUser.Rows[gvUser.EditIndex].FindControl("ddlUserState")).SelectedValue);
        }
    }
    #endregion
   
}